package mse.eai.esb;

import org.jboss.logging.Logger;
import org.jboss.soa.esb.actions.ActionLifecycle;
import org.jboss.soa.esb.actions.ActionLifecycleException;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Message;

public class ImprimeMessage implements ActionLifecycle {

	private static final Logger log = Logger.getLogger(ImprimeMessage.class);

	@Override
	public void destroy() throws ActionLifecycleException {
		// TODO Auto-generated method stub

	}

	@Override
	public void initialise() throws ActionLifecycleException {
		// TODO Auto-generated method stub

	}

	public ImprimeMessage(ConfigTree config) {

	}

	public Message process(Message m) {
		log.info("ESB Action start ------>");

		log.info("-------------- Message content ------------");

		Body b = m.getBody();
		for (String str : b.getNames()) {

			log.info(str + " = " + b.get(str));

		}
		log.info("-------------------------------------------");
		log.info("<------- ESB Action done");
		return m;

	}
}
